<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>岗位新建</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <link rel="stylesheet" th:href="@{/css/formSelects-v4.css}">
    <script type="text/javascript" th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/formSelects-v4.min.js}" charset="utf-8"></script>
</head>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form">
            <div class="layui-form-item">
                <input th:if="${bookInfo!=null}" type="hidden" id="bookId" name="bookId" th:value="${bookInfo?.bookId}">
            </div>
            <div class="layui-form-item">
                <label for="borrowId" class="layui-form-label">
                    <span class="x-red">*</span>借阅人编号</label>
                <div class="layui-input-inline">
                    <input type="text" id="borrowId" name="borrowId" lay-verify="required"
                           placeholder="请输入借阅人编号（必填）" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="submit" lay-submit="">确定</button>
            </div>
        </div>
    </div>
</div>
</div>
<script>

    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(submit)', function (data) {
            console.log(data.field);
            $.ajax({
                url: "/admin/book/borrowBook",
                type: "post",
                data: data.field,
                success: function (s) {
                    if (s.code == 0) {
                        layer.msg(s.msg, function () {
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(s.msg, function () {
                        });
                    }
                },
                error: function () {
                    layer.msg("用户不存在!", function () {
                    });
                }
            });
        });

    });
</script>
</body>

</html>